define(()=>{
    return function (id, price){
        const goods = localStorage.getItem("goods") ? JSON.parse(localStorage.getItem("goods")) : [];
        if(goods.length < 1){
            goods.push({
                id: id,
                num: 1,
                flag: 0,
                price
            })
        }else{
            let i=0;
            const flag = goods.some((val,idx)=>{
                i = idx;
                return val.id === id;
            })
            if(flag){
                goods[i].num++;
            }else{
                goods.push({
                    id: id,
                    num: 1,
                    flag: 0,
                    price
                })
            }
        }
        localStorage.setItem("goods", JSON.stringify(goods));
    }
})